/* Copyright (C) 2015-2016 HangZhou Zenzet Technology Co., Ltd.
 * All right reserved

 * File:crypto/locketaes.h
 * Author:guojianchuan/max
 * Date:2016-06-02

 */

#ifndef _LOCKET_AES_H_
#define _LOCKET_AES_H_

#ifdef __cplusplus
extern "C" {
#endif

/* Declare : Macro/Struct/Enum/Union */

/**
* @Enum: CIPHER_MODE_E
* @Author: guojianchuan/max
* @Date: 2016-06-02
* @Description: AES加密/解密类型
*/
typedef enum tagCipherMode
{
    /* 解密 */
    DECRYPT = 0,

    /* 加密 */
    ENCRYPT = 1
}CIPHER_MODE_E;

/**
* @struct: CIPHER_AES_S 
* @Author: guojianchuan/max
* @Date: 2016-06-02
* @Description: AES结构
*/
typedef struct tagAES
{
    /* 算法名称 格式: 算法-位数-模式 eg:AES-128-CFB*/
    char szAlgoName[64];

    /* 加解密 dec:0 enc:1 */
    int iMode;

    /* AES key */
    unsigned char *pucKey;

    /* AES iv (ECB模式可以设置为NULL)*/
    unsigned char *pucIv;

    /* 输入 */
    unsigned char *pucInput;

    /* 输入长度 */
    int iInputLen;

    /* 输入编码格式 hex:0 base64:1 binary:2 */
    int iInputEncode;

    /* 输出 */
    unsigned char *pucOutput;

    /* 输出长度 */
    int iOutputLen;

    /* 输出编码格式 hex:0 base64:1 binary:2 */
    int iOutputEncode;
}CIPHER_AES_S;

/* Declare: Function */
int LOCKET_CIPHER_AESCrypt(INOUT CIPHER_AES_S *pstAES);

#ifdef __cplusplus
}
#endif

#endif  /* _LOCKET_AES_H_ */
